<template>
	<view class="friend-apply-pop" :class="{'outAni':isInOuting}">
		<image class="apply-msg-img" src="../../static/addFriendPopBg.png"></image>

		<view class="apply-msg-content">
			<view class="content-title">
				<text class="title-text">您有一条好友请求</text>
				<image class="close-icon" src="../../static/closeIcon.png" @tap="closePop"></image>
			</view>

			<view class="apply-from-msg">
				<view class="from-msg-text">{{applyData.fromDesc}}</view>
				<image class="from-msg-avatar" :src="getImgUrl(applyData.fromUserInfo.avatar)"></image>
				<view class="from-msg-text">{{applyData.fromUserInfo.nickName}}</view>
			</view>
			
			<view class="apply-remark">
				{{applyData.fromRemark}}
			</view>
			
			<view class="apply-form-way">
				<text class="fix-text">通过</text>
				<image class="comment-user-avatar" :src="getImgUrl(applyData.fromUserInfo.avatar)"></image>
				<text class="comment-user-name">{{applyData.fromUserInfo.nickName}}</text>
				<text class="fix-text">的{{applyData.fromType}}添加</text>
			</view>
			
			<!-- <view class="apply-form-way">
				<text class="fix-text2">通过手机号添加</text>
			</view> -->
			
			<!-- <view class="apply-form-way">
				<text class="fix-text2">通过微信聊天换货群聊添加</text>
			</view> -->

			<view class="switch-block">
				<view class="switch-block-title">朋友圈状态</view>
				<switchBarItem :name="'不让他（她）看'" :initVal="switch1Val" @switch="toggleSwitch1"></switchBarItem>
				<switchBarItem :name="'不看他（她'" :initVal="switch2Val" @switch="toggleSwitch2"></switchBarItem>
			</view>

			<view class="btns">
				<view class="short-btn" @tap="confirm">同意</view>
				<view class="short-btn red"  @tap="cancel">拒绝</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			applyData: {
				type: Object,
				required: true
			}
		},
		data() {
			return {
				switch1Val: true,
				switch2Val: false,
				isInOuting: false
			}
		},
		mounted() {

		},
		methods: {
			closePop() {
				this.isInOuting = true
				setTimeout(() => {
					this.$emit('close', this.applyData.id)
				}, 300)
			},
			toggleSwitch1(val) {
				this.switch1Val = val
			},
			toggleSwitch2(val) {
				this.switch2Val = val
			},
			confirm(){
				this.$emit('confirm', this.applyData.id)
				this.closePop()
			},
			cancel(){
				this.$emit('cancel', this.applyData.id)
				this.closePop()
			}
		}
	}
</script>

<style lang="less" scoped>
	.friend-apply-pop {
		position: fixed;
		z-index: 100;
		bottom: 0;
		left: 0;
		height: 940rpx;
		width: 100%;
		box-sizing: border-box;
		background-color: #FFFFFF;
		animation: slideIn 0.3s forwards;

		&.outAni {
			animation: slideOut 0.3s forwards;
		}

		.apply-msg-img {
			width: 750rpx;
			height: 594rpx;
		}

		.apply-msg-content {
			position: absolute;
			top: -14rpx;
			left: 0;
			width: 100%;
			padding: 54rpx 56rpx;
			box-sizing: border-box;

			.content-title {
				margin-bottom: 66rpx;
				position: relative;
				height: 50rpx;
				display: flex;
				justify-content: center;

				.title-text {
					font-size: 36rpx;
					font-weight: 500;
					line-height: 50rpx;
				}

				.close-icon {
					width: 56rpx;
					height: 56rpx;
					position: absolute;
					top: -3rpx;
					right: -10rpx;
				}
			}

			.apply-from-msg {
				display: flex;
				align-items: center;
				flex-wrap: wrap;

				.from-msg-avatar {
					width: 60rpx;
					height: 60rpx;
					border-radius: 50%;
					margin: 0 10rpx;
				}

				.from-msg-text {
					font-size: 30rpx;
					font-weight: 600;
					color: #333333;
					line-height: 42rpx;
				}
			}

			.apply-remark {
				box-sizing: border-box;
				padding: 36rpx 0;
				font-size: 30rpx;
				font-weight: 400;
				color: #666;
				line-height: 42rpx;
				text-overflow: ellipsis;
				overflow: hidden;
				white-space: nowrap;
			}

			.apply-form-way {
				width: 630rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				box-sizing: border-box;
				padding: 12rpx 20rpx;
				background-color: rgba(254, 241, 229, 0.5);
				margin-top: 18rpx;

				.fix-text {
					font-size: 28rpx;
					font-weight: 400;
					color: #333333;
					line-height: 40rpx;
				}
				
				.fix-text2 {
					flex: 1;
					font-size: 28rpx;
					font-weight: 400;
					color: #333333;
					line-height: 40rpx;
				}

				.comment-user-avatar {
					width: 64rpx;
					height: 64rpx;
					border-radius: 50%;
					margin: 0 18rpx;
				}

				.comment-user-name {
					font-size: 28rpx;
					font-weight: 600;
					color: #333333;
					line-height: 40rpx;
					margin-right: 18rpx;
				}
			}

			.btns {
				margin-top: 50rpx;
				display: flex;
				justify-content: space-between;
				padding: 0 10rpx;

				.short-btn {
					height: 76rpx;
					width: 260rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-size: 30rpx;
					color: #fff;
					background: #444;

					&.red {
						background: #FF4C4C;
					}
				}
			}

		}
	}

	.switch-block {
		margin-top: 40rpx;

		.switch-block-title {
			font-size: 32rpx;
			font-weight: 600;
			color: #4A505C;
			line-height: 44rpx;
			margin-bottom: 20rpx;
		}
	}

	@keyframes slideIn {
		0% {
			transform: translateY(100%);
		}

		100% {
			transform: translateY(0);
		}
	}

	@keyframes slideOut {
		0% {
			transform: translateY(0);
		}

		100% {
			transform: translateY(100%);
		}
	}
</style>
